<template>
  <div class="login-container">
    <form @submit.prevent="handleLogin" class="login-form">
      <h2>画家油画作品管理系统</h2>
      <div class="form-group">
        <label>账号：</label>
        <input
          type="text"
          v-model="username"
          placeholder="默认账号: curator"
          required
        />
      </div>
      <div class="form-group">
        <label>密码：</label>
        <input
          type="password"
          v-model="password"
          placeholder="默认密码: 123456"
          required
        />
      </div>
      <div class="form-tips">
        提示：默认账号 curator，密码 123456
      </div>
      <button type="submit" class="login-btn">登录 🎨</button>
    </form>
  </div>
</template>

<script setup>
import { ref } from 'vue'
import { useRouter } from 'vue-router'
import { ElMessage } from 'element-plus'

const username = ref('')
const password = ref('')
const router = useRouter()

// 默认管理员账号
const DEFAULT_USERNAME = 'curator'
const DEFAULT_PASSWORD = '123456'

const handleLogin = () => {
  // 检查是否为默认账号
  if (username.value === DEFAULT_USERNAME && password.value === DEFAULT_PASSWORD) {
    ElMessage.success('身份验证成功！欢迎进入艺术典藏系统')
    // 存储登录状态
    localStorage.setItem('isLoggedIn', 'true')
    localStorage.setItem('username', username.value)
    router.push('/home/page1')
  } else {
    ElMessage.error('认证失败，请检查账号和密码')
    password.value = ''
  }
}
</script>

<style scoped>
.login-container {
  display: flex;
  justify-content: flex-end;
  align-items: center;
  height: 100vh;
  background-size: cover;
  background-position: center;
  font-family: 'Georgia', 'Times New Roman', serif;
  background-image: url('../../assets/2.png');
}

.login-form {
  background: rgba(255, 255, 255, 0.25);
  padding: 2.5rem;
  border-radius: 25px;
  box-shadow: 0 8px 32px rgba(42, 61, 102, 0.15);
  width: 380px;
  backdrop-filter: blur(8px);
  border: 2px solid #2a3d66;
  transform: translateY(-10px);
  margin-right: 10%;
}

h2 {
  text-align: center;
  color: #2a3d66;
  margin-bottom: 2rem;
  font-size: 28px;
  letter-spacing: 1.5px;
  text-shadow: 2px 2px 4px rgba(42, 61, 102, 0.1);
  position: relative;
}

h2::after {
  content: '';
  position: absolute;
  bottom: -10px;
  left: 50%;
  transform: translateX(-50%);
  width: 60px;
  height: 3px;
  background: #c19a6b;
  border-radius: 2px;
}

.form-group {
  margin-bottom: 1.8rem;
}

.form-tips {
  text-align: center;
  color: #666;
  margin-bottom: 1rem;
  font-size: 0.9em;
  padding: 8px;
  background: rgba(255, 255, 255, 0.5);
  border-radius: 8px;
}

label {
  display: block;
  margin-bottom: 0.8rem;
  color: #5a4e41;
  font-weight: 600;
  font-size: 15px;
}

input {
  width: 100%;
  padding: 14px;
  border: 2px solid #b0a18f;
  border-radius: 12px;
  box-sizing: border-box;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  background: rgba(255, 255, 255, 0.9);
  font-size: 14px;
  color: #4a4136;
}

input:focus {
  border-color: #2a3d66;
  box-shadow: 0 0 12px rgba(42, 61, 102, 0.2);
  background: rgba(255, 255, 255, 1);
}

.login-btn {
  width: 100%;
  padding: 16px;
  background: linear-gradient(135deg, #2a3d66, #475f8d);
  color: #f4e9d8;
  border: none;
  border-radius: 12px;
  cursor: pointer;
  font-size: 16px;
  font-weight: 600;
  letter-spacing: 1.5px;
  transition: 
    transform 0.2s ease,
    box-shadow 0.3s cubic-bezier(0.4, 0, 0.2, 1),
    opacity 0.2s ease;
  margin-top: 10px;
}

.login-btn:hover {
  transform: translateY(-2px);
  box-shadow: 
    0 6px 20px rgba(42, 61, 102, 0.25),
    0 4px 12px rgba(71, 95, 141, 0.2);
  opacity: 0.95;
}

.login-btn:active {
  transform: translateY(0);
  box-shadow: 
    0 3px 10px rgba(42, 61, 102, 0.15),
    0 2px 6px rgba(71, 95, 141, 0.1);
}
</style>